package PRIO;

import java.util.Arrays;
import java.util.PriorityQueue;

class Student{//自定义类

}

public class Test {
    public static void main4(String[] args) {
        PriorityQueue<Student> priorityQueue = new PriorityQueue<>();
        //由于Studen是自定义类,当我们将它放到堆里面时,由于堆分为小根堆和大根堆,它默认按照小根堆进行比较
        //但对于Student这个自定义类来说,它并不能直接直接使用,他需要我们自己实现CompareAble这个接口重写比较规则.否则下面运行代码会出现报错
        priorityQueue.offer(new Student());
        priorityQueue.offer(new Student());
    }


    public static void main3(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        priorityQueue.offer(10);
        priorityQueue.offer(4);
        priorityQueue.offer(8);
        priorityQueue.offer(3);

        System.out.println(priorityQueue.poll());
        System.out.println(priorityQueue.poll());
    }

    public static void main(String[] args) {
        //大根堆测试代码
        int[] array = {27 , 15 , 19 , 18 , 28 , 34 , 65 , 49 , 25 , 37};
        TestHeap testHeap = new TestHeap(array);
        testHeap.initElem(array);
        testHeap.createBigHeap();
        System.out.println("=====");
        //堆排序测试
        testHeap.heapSort();

        System.out.println("****************");


//        System.out.println(testHeap.poll());//删除测试
//        System.out.println("===========");
//        testHeap.offer(100);
//        System.out.println("+++++++++++");

        //小根堆测试代码
        int[] array2 = {27 , 15 , 19 , 18 , 28 , 34 , 65 , 49 , 25 , 37};
        TestHeap testHeap2 = new TestHeap(array2);
        testHeap2.initElem(array2);
        testHeap2.createBigHeap2();
        System.out.println("----");


        //
    }
}
